<?php

class CandidateSelectorHelper extends AppHelper {
	var $helpers = array('Html', 'Ajax');

	function makeSelector($firstName, $lastName, $attitude) {
		$tdId = $firstName.'-'.$lastName;
             $likeParam = 'like';
             $dislikeParam = 'dislike';
             $likeImage = 'like_gray.png';
             $dislikeImage = 'dislike_gray.png';
             if (isset($attitude)) {
               if ($attitude) {
                 $likeImage = 'like.png';
                 $likeParam = 'neutral';
               }
               else {
                 $dislikeImage = 'dislike.png';
                 $dislikeParam = 'neutral';
               }
             }
             
		$likeLink = $this->Ajax->link(
			$this->Html->image($likeImage, array('alt'=> __("Like", true), 'border'=>"0")),
			array( 'controller' => 'ballots', 'action' => 'setAttitude', $likeParam, $firstName, $lastName ),
			array( 'update' => $tdId, 'title' => 'I like this candidate.'),
			null,
			false
		);
		 
    $dislikeLink = $this->Ajax->link(
      $this->Html->image($dislikeImage, array('alt'=> __("Dislike", true), 'border'=>"0")),
      array( 'controller' => 'ballots', 'action' => 'setAttitude', $dislikeParam, $firstName, $lastName ),
      array( 'update' => $tdId, 'title' => 'I do not like this candidate.'),
      null,
      false
    );
    
    return $this->output("<div id=$tdId class=\"candidateSelector\"> $likeLink $dislikeLink <div>");
	}
}

?>